#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include "public.h"

/*
 * abstruct : main program.
 */

int main(int argc, char ** argv)
{
	int com;
	unsigned char buffer[] = "123";
	pthread_t com_read_id;

	void * ptr;
	pthread_attr_t attr;

	if (argc != 2) {
		printf("usage: %s 0|1|2|3.\n", argv[0]);
		exit(0);
	}
	
	com = atoi(argv[1]);
	uart_init(com, 115200, 8, 1, 'n');

	/* for send test */
	while (0) {
		uart_send(buffer, sizeof(buffer));
		msleep(1000);
	}

	pthread_attr_init(&attr);

	com_read_id = 0;
	pthread_create(&com_read_id, &attr, uart_receive_thread, NULL);

	pthread_join(com_read_id, & ptr);



	return 0;
}

